<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css"/>
    <style>
        .layui-form-select dl{
            max-height: 180px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" style="padding-right: 30px">
    <div class="main-container">
        <div class="layui-row layui-col-space1">
            <div class="layui-col-md12">
                <input type="hidden" name="personId" value="${personId!}">
                <input type="hidden" name="pointInfo" value="">
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">违章时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="wzTime" id="wzTime" lay-verify="datetime" placeholder="" autocomplete="off"
                                   class="layui-input" value="">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">违章信息</label>
                        <div class="layui-input-block">
                            <select name="pointId" lay-verify="required" lay-filter="test" required lay-search="">
                                <option value="" selected>请选择</option>
                                @for(item in wzPoint!){
                                <option value="${item.id}" pointName="${item.point!}">${item.point}分 - ${item.name!}</option>
                                @}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">违章扣分</label>
                        <div class="layui-input-block">
                            <input type="text" name="wzPoint" lay-verify="required" required readonly placeholder=""
                                   class="layui-input" value="">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">违章截图</label>
                        <div class="layui-input-block">
                            <input type="file" id="wzImage" name="wzImage" />
                        </div>
                    </div>
                </div>
            </div>
            </div>
        </div>
    </div>

    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-md">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>

</form>
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'select', 'code', 'element','laydate'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#wzTime',
            type: 'datetime',
            position: 'fixed'
        });
        form.on('select(test)', function(data){
            var point=$(data.elem[data.elem.selectedIndex]).attr('pointName');
            var wzinfo=data.elem[data.elem.selectedIndex].text;
            $("[name=wzPoint]").val(point);
            $("[name=pointInfo]").val(wzinfo);
        });
        let VIEW_PATH = "${ctxPath}/busPerson/view/";
        let DATA_PATH = "${ctxPath}/busPerson/data/";
        layui.code();
        form.on('submit(user-save)', function (data) {
            $.ajax({
                url: DATA_PATH + 'koufen',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 0) {
                        layer.msg("操作成功", {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("busPerson-table");
                        });
                    } else {
                        layer.msg("操作失败", {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });

    })
</script>
</body>
</html>